/*
 * @Description:
 * @Author: ldx
 * @Date: 2022-09-17 22:04:14
 * @LastEditors: ldx
 * @LastEditTime: 2022-09-20 22:46:35
 */
import axios from '@/utils/axios'

import { Pagination } from '../types'
/** 设备信息列表 */
export async function queryEquip(
  { current, pageSize }: Pagination,
  params: any
): Promise<any> {
  return axios
    .post<any & Pagination, any>(`/ivr/equip/page`, {
      ...params,
      pageSize,
      pageNum: current
    })
    .then((res) => ({
      total: res.data.total,
      list: res.data.records
    }))
}
/** 设备信息详情 */
export const queryDetails = (id: string): Promise<any> => {
  return axios.get<unknown, any>(`/ivr/equip/details/${id}`)
}

/** 设备信息删除 */
export const deleteEquip = (id: string): Promise<any> => {
  return axios.post<unknown, any>(`/ivr/equip/delete/${id}`)
}
/** 设备信息下载 */
export const downloadEquip = (id: string): Promise<any> => {
  return axios.request<unknown, any>({
    url: `/ivr/equip/download/${id}`,
    method: 'get',
    responseType: 'arraybuffer'
  })
}
/** 创建设备信息 */
export const createEquip = (data: any): Promise<any> => {
  return axios.post<any & Pagination, any>(`/ivr/equip/create`, data)
}
/** 更新设备信息 */
export const updateEquip = (data: any): Promise<any> => {
  return axios.post<any & Pagination, any>(`/ivr/equip/update`, data)
}
